package view;

import model.Arc;
import model.Graph;
import model.Noeud;
import test.Application;

import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: Thomas
 * Date: 18/02/14
 * Time: 09:12
 */
public class Window {
    private JToolBar jToolBarHistory = new JToolBar();
    private JCanvas jCanvas = new JCanvas();
    private JButton jButtonSource = new JButton("Source");
    private JButton jButtonDestination = new JButton("Destination");

    public void initCanvas() {
        Graph graph = Application.getGraphS();

        this.getjCanvas().setBackground(Color.WHITE);
        this.getjCanvas().setPreferredSize(new Dimension(400, 200));

        this.getjCanvas().clear();

        for(Map.Entry<Integer, Noeud> entry : graph.getNoeuds().entrySet()) {
            Noeud noeud = entry.getValue();
            this.getjCanvas().addDrawable(noeud.getNoeudDrawable());
        }

        for(Map.Entry<String, ArrayList<Arc>> arcs : graph.getArcs().entrySet()) {
            for (Arc arc : arcs.getValue()) {
                this.getjCanvas().addDrawable(arc.getArcDrawable());
            }
        }
    }

    public JToolBar getjToolBarHistory() {
        return this.jToolBarHistory;
    }

    public void setjToolBarHistory(JToolBar jToolBarHistory) {
        this.jToolBarHistory = jToolBarHistory;
    }

    public JCanvas getjCanvas() {
        return jCanvas;
    }

    public void setjCanvas(JCanvas jCanvas) {
        this.jCanvas = jCanvas;
    }

    public JButton getjButtonSource() {
        return jButtonSource;
    }

    public JButton getjButtonDestination() {
        return jButtonDestination;
    }
}
